
<?php
class models_chungloai extends connect
{
	function listchungloai()
	{
		$sql = 'SELECT * FROM chungloai'; //tao lenh truy van
		$this->query_db($sql); //Thuc thi cau lenh sql 
		return $this->fetchAll();//tra ve tat cac dong trong bang
	}
	function _addchungloai($TenCL)
	{
		$sql = "INSERT INTO chungloai VALUES('','$TenCL')";
		$this->query_db($sql);
	}
	function del_chungloai($intMa)
	{
		$sql = "DELETE FROM chungloai WHERE MaCL = $intMa";
		$this->query_db($sql);
	}
	function getChungLoai($intMa)
	{
		$sql = "SELECT * FROM chungloai WHERE MaCL = $intMa";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	function updateChungLoai($TenCL,$intMa)
	{
		$sql ="UPDATE chungloai
				SET 
					TenCL = '$TenCL'
				WHERE MaCL = '$intMa'";
		$this->query_db($sql);
	}
	function listchungloainam()
	{
		$sql = 'SELECT MaCL,TenCL
				FROM chungloai
				WHERE MaCL=1'
		; //tao lenh truy van
		$this->query_db($sql); //Thuc thi cau lenh sql 
		return $this->fetchOne();//tra ve tat cac dong trong bang
	}
	function listchungloainu()
	{
		$sql = 'SELECT MaCL,TenCL
				FROM chungloai
				WHERE MaCL=2'
		; //tao lenh truy van
		$this->query_db($sql); //Thuc thi cau lenh sql 
		return $this->fetchOne();//tra ve tat cac dong trong bang
	}
	function listchungloaite()
	{
		$sql = 'SELECT MaCL,TenCL
				FROM chungloai
				WHERE MaCL=3'
		; //tao lenh truy van
		$this->query_db($sql); //Thuc thi cau lenh sql 
		return $this->fetchOne();//tra ve tat cac dong trong bang
	}
}
?>